<?php
	/**
	 * This is a MetaControl class, providing a QForm or QPanel access to event handlers
	 * and QControls to perform the Create, Edit, and Delete functionality
	 * of the Project class.  This code-generated class
	 * contains all the basic elements to help a QPanel or QForm display an HTML form that can
	 * manipulate a single Project object.
	 *
	 * To take advantage of some (or all) of these control objects, you
	 * must create a new QForm or QPanel which instantiates a ProjectMetaControl
	 * class.
	 *
	 * Any and all changes to this file will be overwritten with any subsequent
	 * code re-generation.
	 *
	 * @package flx_qcubed
	 * @subpackage MetaControls
	 * @property-read Project $Project the actual Project data class being edited
	 * @property QLabel $IdControl
	 * @property-read QLabel $IdLabel
	 * @property QTextBox $NameControl
	 * @property-read QLabel $NameLabel
	 * @property QDateTimePicker $DateControl
	 * @property-read QLabel $DateLabel
	 * @property QCheckBox $IsEnableControl
	 * @property-read QLabel $IsEnableLabel
	 * @property QTextBox $DescriptionControl
	 * @property-read QLabel $DescriptionLabel
	 * @property QTextBox $LogUserControl
	 * @property-read QLabel $LogUserLabel
	 * @property QDateTimePicker $LogInsertControl
	 * @property-read QLabel $LogInsertLabel
	 * @property QLabel $LogUpdateControl
	 * @property-read QLabel $LogUpdateLabel
	 * @property-read string $TitleVerb a verb indicating whether or not this is being edited or created
	 * @property-read boolean $EditMode a boolean indicating whether or not this is being edited or created
	 */

	class ProjectMetaControlGen extends QBaseClass {
		// General Variables
		/**
		 * @var Project objProject
		 * @access protected
		 */
		protected $objProject;
		/**
		 * @var QForm|QControl objParentObject
		 * @access protected
		 */
		protected $objParentObject;
		/**
		 * @var string strTitleVerb
		 * @access protected
		 */
		protected $strTitleVerb;
		/**
		 * @var boolean blnEditMode
		 * @access protected
		 */
		protected $blnEditMode;

		// Controls that allow the editing of Project's individual data fields
		/**
		 * @var QLabel lblId
		 * @access protected
		 */
		protected $lblId;
		/**
		 * @var QTextBox txtName
		 * @access protected
		 */
		protected $txtName;
		/**
		 * @var QDateTimePicker calDate
		 * @access protected
		 */
		protected $calDate;
		/**
		 * @var QCheckBox chkIsEnable
		 * @access protected
		 */
		protected $chkIsEnable;
		/**
		 * @var QTextBox txtDescription
		 * @access protected
		 */
		protected $txtDescription;
		/**
		 * @var QTextBox txtLogUser
		 * @access protected
		 */
		protected $txtLogUser;
		/**
		 * @var QDateTimePicker calLogInsert
		 * @access protected
		 */
		protected $calLogInsert;
		/**
		 * @var QLabel lblLogUpdate
		 * @access protected
		 */
		protected $lblLogUpdate;

		// Controls that allow the viewing of Project's individual data fields
		/**
		 * @var QLabel lblName
		 * @access protected
		 */
		protected $lblName;
		/**
		 * @var QLabel lblDate
		 * @access protected
		 */
		protected $lblDate;
		/**
		 * @var QLabel lblIsEnable
		 * @access protected
		 */
		protected $lblIsEnable;
		/**
		 * @var QLabel lblDescription
		 * @access protected
		 */
		protected $lblDescription;
		/**
		 * @var QLabel lblLogUser
		 * @access protected
		 */
		protected $lblLogUser;
		/**
		 * @var QLabel lblLogInsert
		 * @access protected
		 */
		protected $lblLogInsert;

		// QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References

		// QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References


		/**
		 * Main constructor.  Constructor OR static create methods are designed to be called in either
		 * a parent QPanel or the main QForm when wanting to create a
		 * ProjectMetaControl to edit a single Project object within the
		 * QPanel or QForm.
		 *
		 * This constructor takes in a single Project object, while any of the static
		 * create methods below can be used to construct based off of individual PK ID(s).
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this ProjectMetaControl
		 * @param Project $objProject new or existing Project object
		 */
		 public function __construct($objParentObject, Project $objProject) {
			// Setup Parent Object (e.g. QForm or QPanel which will be using this ProjectMetaControl)
			$this->objParentObject = $objParentObject;

			// Setup linked Project object
			$this->objProject = $objProject;

			// Figure out if we're Editing or Creating New
			if ($this->objProject->__Restored) {
				$this->strTitleVerb = QApplication::Translate('Edit');
				$this->blnEditMode = true;
			} else {
				$this->strTitleVerb = QApplication::Translate('Create');
				$this->blnEditMode = false;
			}
		 }

		/**
		 * Static Helper Method to Create using PK arguments
		 * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
		 * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
		 * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to
		 * edit, or if we are also allowed to create a new one, etc.
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this ProjectMetaControl
		 * @param integer $intId primary key value
		 * @param QMetaControlCreateType $intCreateType rules governing Project object creation - defaults to CreateOrEdit
 		 * @return ProjectMetaControl
		 */
		public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			// Attempt to Load from PK Arguments
			if (strlen($intId)) {
				$objProject = Project::Load($intId);

				// Project was found -- return it!
				if ($objProject)
					return new ProjectMetaControl($objParentObject, $objProject);

				// If CreateOnRecordNotFound not specified, throw an exception
				else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
					throw new QCallerException('Could not find a Project object with PK arguments: ' . $intId);

			// If EditOnly is specified, throw an exception
			} else if ($intCreateType == QMetaControlCreateType::EditOnly)
				throw new QCallerException('No PK arguments specified');

			// If we are here, then we need to create a new record
			return new ProjectMetaControl($objParentObject, new Project());
		}

		/**
		 * Static Helper Method to Create using PathInfo arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this ProjectMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing Project object creation - defaults to CreateOrEdit
		 * @return ProjectMetaControl
		 */
		public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$intId = QApplication::PathInfo(0);
			return ProjectMetaControl::Create($objParentObject, $intId, $intCreateType);
		}

		/**
		 * Static Helper Method to Create using QueryString arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this ProjectMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing Project object creation - defaults to CreateOrEdit
		 * @return ProjectMetaControl
		 */
		public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$intId = QApplication::QueryString('intId');
			return ProjectMetaControl::Create($objParentObject, $intId, $intCreateType);
		}



		///////////////////////////////////////////////
		// PUBLIC CREATE and REFRESH METHODS
		///////////////////////////////////////////////

		/**
		 * Create and setup QLabel lblId
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblId_Create($strControlId = null) {
			$this->lblId = new QLabel($this->objParentObject, $strControlId);
			$this->lblId->Name = QApplication::Translate('Id');
			if ($this->blnEditMode)
				$this->lblId->Text = $this->objProject->Id;
			else
				$this->lblId->Text = 'N/A';
			return $this->lblId;
		}

		/**
		 * Create and setup QTextBox txtName
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtName_Create($strControlId = null) {
			$this->txtName = new QTextBox($this->objParentObject, $strControlId);
			$this->txtName->Name = QApplication::Translate('Name');
			$this->txtName->Text = $this->objProject->Name;
			$this->txtName->Required = true;
			$this->txtName->MaxLength = Project::NameMaxLength;
			return $this->txtName;
		}

		/**
		 * Create and setup QLabel lblName
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblName_Create($strControlId = null) {
			$this->lblName = new QLabel($this->objParentObject, $strControlId);
			$this->lblName->Name = QApplication::Translate('Name');
			$this->lblName->Text = $this->objProject->Name;
			$this->lblName->Required = true;
			return $this->lblName;
		}

		/**
		 * Create and setup QDateTimePicker calDate
		 * @param string $strControlId optional ControlId to use
		 * @return QDateTimePicker
		 */
		public function calDate_Create($strControlId = null) {
			$this->calDate = new QDateTimePicker($this->objParentObject, $strControlId);
			$this->calDate->Name = QApplication::Translate('Date');
			$this->calDate->DateTime = $this->objProject->Date;
			$this->calDate->DateTimePickerType = QDateTimePickerType::DateTime;
			$this->calDate->Required = true;
			return $this->calDate;
		}

		/**
		 * Create and setup QLabel lblDate
		 * @param string $strControlId optional ControlId to use
		 * @param string $strDateTimeFormat optional DateTimeFormat to use
		 * @return QLabel
		 */
		public function lblDate_Create($strControlId = null, $strDateTimeFormat = null) {
			$this->lblDate = new QLabel($this->objParentObject, $strControlId);
			$this->lblDate->Name = QApplication::Translate('Date');
			$this->strDateDateTimeFormat = $strDateTimeFormat;
			$this->lblDate->Text = sprintf($this->objProject->Date) ? $this->objProject->Date->qFormat($this->strDateDateTimeFormat) : null;
			$this->lblDate->Required = true;
			return $this->lblDate;
		}

		protected $strDateDateTimeFormat;


		/**
		 * Create and setup QCheckBox chkIsEnable
		 * @param string $strControlId optional ControlId to use
		 * @return QCheckBox
		 */
		public function chkIsEnable_Create($strControlId = null) {
			$this->chkIsEnable = new QCheckBox($this->objParentObject, $strControlId);
			$this->chkIsEnable->Name = QApplication::Translate('Is Enable');
			$this->chkIsEnable->Checked = $this->objProject->IsEnable;
			return $this->chkIsEnable;
		}

		/**
		 * Create and setup QLabel lblIsEnable
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblIsEnable_Create($strControlId = null) {
			$this->lblIsEnable = new QLabel($this->objParentObject, $strControlId);
			$this->lblIsEnable->Name = QApplication::Translate('Is Enable');
			$this->lblIsEnable->Text = ($this->objProject->IsEnable) ? QApplication::Translate('Yes') : QApplication::Translate('No');
			return $this->lblIsEnable;
		}

		/**
		 * Create and setup QTextBox txtDescription
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtDescription_Create($strControlId = null) {
			$this->txtDescription = new QTextBox($this->objParentObject, $strControlId);
			$this->txtDescription->Name = QApplication::Translate('Description');
			$this->txtDescription->Text = $this->objProject->Description;
			$this->txtDescription->Required = true;
			$this->txtDescription->MaxLength = Project::DescriptionMaxLength;
			return $this->txtDescription;
		}

		/**
		 * Create and setup QLabel lblDescription
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblDescription_Create($strControlId = null) {
			$this->lblDescription = new QLabel($this->objParentObject, $strControlId);
			$this->lblDescription->Name = QApplication::Translate('Description');
			$this->lblDescription->Text = $this->objProject->Description;
			$this->lblDescription->Required = true;
			return $this->lblDescription;
		}

		/**
		 * Create and setup QTextBox txtLogUser
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtLogUser_Create($strControlId = null) {
			$this->txtLogUser = new QTextBox($this->objParentObject, $strControlId);
			$this->txtLogUser->Name = QApplication::Translate('Log User');
			$this->txtLogUser->Text = $this->objProject->LogUser;
			$this->txtLogUser->MaxLength = Project::LogUserMaxLength;
			return $this->txtLogUser;
		}

		/**
		 * Create and setup QLabel lblLogUser
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblLogUser_Create($strControlId = null) {
			$this->lblLogUser = new QLabel($this->objParentObject, $strControlId);
			$this->lblLogUser->Name = QApplication::Translate('Log User');
			$this->lblLogUser->Text = $this->objProject->LogUser;
			return $this->lblLogUser;
		}

		/**
		 * Create and setup QDateTimePicker calLogInsert
		 * @param string $strControlId optional ControlId to use
		 * @return QDateTimePicker
		 */
		public function calLogInsert_Create($strControlId = null) {
			$this->calLogInsert = new QDateTimePicker($this->objParentObject, $strControlId);
			$this->calLogInsert->Name = QApplication::Translate('Log Insert');
			$this->calLogInsert->DateTime = $this->objProject->LogInsert;
			$this->calLogInsert->DateTimePickerType = QDateTimePickerType::DateTime;
			return $this->calLogInsert;
		}

		/**
		 * Create and setup QLabel lblLogInsert
		 * @param string $strControlId optional ControlId to use
		 * @param string $strDateTimeFormat optional DateTimeFormat to use
		 * @return QLabel
		 */
		public function lblLogInsert_Create($strControlId = null, $strDateTimeFormat = null) {
			$this->lblLogInsert = new QLabel($this->objParentObject, $strControlId);
			$this->lblLogInsert->Name = QApplication::Translate('Log Insert');
			$this->strLogInsertDateTimeFormat = $strDateTimeFormat;
			$this->lblLogInsert->Text = sprintf($this->objProject->LogInsert) ? $this->objProject->LogInsert->qFormat($this->strLogInsertDateTimeFormat) : null;
			return $this->lblLogInsert;
		}

		protected $strLogInsertDateTimeFormat;


		/**
		 * Create and setup QLabel lblLogUpdate
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblLogUpdate_Create($strControlId = null) {
			$this->lblLogUpdate = new QLabel($this->objParentObject, $strControlId);
			$this->lblLogUpdate->Name = QApplication::Translate('Log Update');
			if ($this->blnEditMode)
				$this->lblLogUpdate->Text = $this->objProject->LogUpdate;
			else
				$this->lblLogUpdate->Text = 'N/A';
			return $this->lblLogUpdate;
		}



		/**
		 * Refresh this MetaControl with Data from the local Project object.
		 * @param boolean $blnReload reload Project from the database
		 * @return void
		 */
		public function Refresh($blnReload = false) {
			if ($blnReload)
				$this->objProject->Reload();

			if ($this->lblId) if ($this->blnEditMode) $this->lblId->Text = $this->objProject->Id;

			if ($this->txtName) $this->txtName->Text = $this->objProject->Name;
			if ($this->lblName) $this->lblName->Text = $this->objProject->Name;

			if ($this->calDate) $this->calDate->DateTime = $this->objProject->Date;
			if ($this->lblDate) $this->lblDate->Text = sprintf($this->objProject->Date) ? $this->objProject->Date->qFormat($this->strDateDateTimeFormat) : null;

			if ($this->chkIsEnable) $this->chkIsEnable->Checked = $this->objProject->IsEnable;
			if ($this->lblIsEnable) $this->lblIsEnable->Text = ($this->objProject->IsEnable) ? QApplication::Translate('Yes') : QApplication::Translate('No');

			if ($this->txtDescription) $this->txtDescription->Text = $this->objProject->Description;
			if ($this->lblDescription) $this->lblDescription->Text = $this->objProject->Description;

			if ($this->txtLogUser) $this->txtLogUser->Text = $this->objProject->LogUser;
			if ($this->lblLogUser) $this->lblLogUser->Text = $this->objProject->LogUser;

			if ($this->calLogInsert) $this->calLogInsert->DateTime = $this->objProject->LogInsert;
			if ($this->lblLogInsert) $this->lblLogInsert->Text = sprintf($this->objProject->LogInsert) ? $this->objProject->LogInsert->qFormat($this->strLogInsertDateTimeFormat) : null;

			if ($this->lblLogUpdate) if ($this->blnEditMode) $this->lblLogUpdate->Text = $this->objProject->LogUpdate;

		}



		///////////////////////////////////////////////
		// PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
		///////////////////////////////////////////////





		///////////////////////////////////////////////
		// PUBLIC PROJECT OBJECT MANIPULATORS
		///////////////////////////////////////////////

		/**
		 * This will save this object's Project instance,
		 * updating only the fields which have had a control created for it.
		 */
		public function SaveProject() {
			try {
				// Update any fields for controls that have been created
				if ($this->txtName) $this->objProject->Name = $this->txtName->Text;
				if ($this->calDate) $this->objProject->Date = $this->calDate->DateTime;
				if ($this->chkIsEnable) $this->objProject->IsEnable = $this->chkIsEnable->Checked;
				if ($this->txtDescription) $this->objProject->Description = $this->txtDescription->Text;
				if ($this->txtLogUser) $this->objProject->LogUser = $this->txtLogUser->Text;
				if ($this->calLogInsert) $this->objProject->LogInsert = $this->calLogInsert->DateTime;

				// Update any UniqueReverseReferences (if any) for controls that have been created for it

				// Save the Project object
				$this->objProject->Save();

				// Finally, update any ManyToManyReferences (if any)
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * This will DELETE this object's Project instance from the database.
		 * It will also unassociate itself from any ManyToManyReferences.
		 */
		public function DeleteProject() {
			$this->objProject->Delete();
		}



		///////////////////////////////////////////////
		// PUBLIC GETTERS and SETTERS
		///////////////////////////////////////////////

		/**
		 * Override method to perform a property "Get"
		 * This will get the value of $strName
		 *
		 * @param string $strName Name of the property to get
		 * @return mixed
		 */
		public function __get($strName) {
			switch ($strName) {
				// General MetaControlVariables
				case 'Project': return $this->objProject;
				case 'TitleVerb': return $this->strTitleVerb;
				case 'EditMode': return $this->blnEditMode;

				// Controls that point to Project fields -- will be created dynamically if not yet created
				case 'IdControl':
					if (!$this->lblId) return $this->lblId_Create();
					return $this->lblId;
				case 'IdLabel':
					if (!$this->lblId) return $this->lblId_Create();
					return $this->lblId;
				case 'NameControl':
					if (!$this->txtName) return $this->txtName_Create();
					return $this->txtName;
				case 'NameLabel':
					if (!$this->lblName) return $this->lblName_Create();
					return $this->lblName;
				case 'DateControl':
					if (!$this->calDate) return $this->calDate_Create();
					return $this->calDate;
				case 'DateLabel':
					if (!$this->lblDate) return $this->lblDate_Create();
					return $this->lblDate;
				case 'IsEnableControl':
					if (!$this->chkIsEnable) return $this->chkIsEnable_Create();
					return $this->chkIsEnable;
				case 'IsEnableLabel':
					if (!$this->lblIsEnable) return $this->lblIsEnable_Create();
					return $this->lblIsEnable;
				case 'DescriptionControl':
					if (!$this->txtDescription) return $this->txtDescription_Create();
					return $this->txtDescription;
				case 'DescriptionLabel':
					if (!$this->lblDescription) return $this->lblDescription_Create();
					return $this->lblDescription;
				case 'LogUserControl':
					if (!$this->txtLogUser) return $this->txtLogUser_Create();
					return $this->txtLogUser;
				case 'LogUserLabel':
					if (!$this->lblLogUser) return $this->lblLogUser_Create();
					return $this->lblLogUser;
				case 'LogInsertControl':
					if (!$this->calLogInsert) return $this->calLogInsert_Create();
					return $this->calLogInsert;
				case 'LogInsertLabel':
					if (!$this->lblLogInsert) return $this->lblLogInsert_Create();
					return $this->lblLogInsert;
				case 'LogUpdateControl':
					if (!$this->lblLogUpdate) return $this->lblLogUpdate_Create();
					return $this->lblLogUpdate;
				case 'LogUpdateLabel':
					if (!$this->lblLogUpdate) return $this->lblLogUpdate_Create();
					return $this->lblLogUpdate;
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

		/**
		 * Override method to perform a property "Set"
		 * This will set the property $strName to be $mixValue
		 *
		 * @param string $strName Name of the property to set
		 * @param string $mixValue New value of the property
		 * @return mixed
		 */
		public function __set($strName, $mixValue) {
			try {
				switch ($strName) {
					// Controls that point to Project fields
					case 'IdControl':
						return ($this->lblId = QType::Cast($mixValue, 'QControl'));
					case 'NameControl':
						return ($this->txtName = QType::Cast($mixValue, 'QControl'));
					case 'DateControl':
						return ($this->calDate = QType::Cast($mixValue, 'QControl'));
					case 'IsEnableControl':
						return ($this->chkIsEnable = QType::Cast($mixValue, 'QControl'));
					case 'DescriptionControl':
						return ($this->txtDescription = QType::Cast($mixValue, 'QControl'));
					case 'LogUserControl':
						return ($this->txtLogUser = QType::Cast($mixValue, 'QControl'));
					case 'LogInsertControl':
						return ($this->calLogInsert = QType::Cast($mixValue, 'QControl'));
					case 'LogUpdateControl':
						return ($this->lblLogUpdate = QType::Cast($mixValue, 'QControl'));
					default:
						return parent::__set($strName, $mixValue);
				}
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}
	}
?>